//
//  InformationTableViewCell.m
//  HQJFacilitator
//
//  Created by mymac on 16/9/23.
//  Copyright © 2016年 Fujian first time iot technology investment co., LTD. All rights reserved.
//

#import "InformationTableViewCell.h"


@interface InformationTableViewCell ()

@end
@implementation InformationTableViewCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        //        [self initialize];
    }
    
    
    
    return self;
}
-(UILabel *)titleLabel {
    
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc]init];
        _titleLabel.font = [UIFont systemFontOfSize:17];
        [self addSubview:_titleLabel];
    }
    
    return _titleLabel ;
}
-(UILabel *)contentLabel {
    
    if (!_contentLabel) {
        _contentLabel = [[UILabel alloc]init];
       _contentLabel.textColor = [ManagerEngine getColor:@"999999"];

        _contentLabel.font = [UIFont systemFontOfSize:17];
        [self addSubview:self.contentLabel];

    }
    
    
    
    return _contentLabel;
}

-(void)initialize {
 
    CGFloat  titleRect = [ManagerEngine setTextWidthStr:self.titleLabel.text andFont:[UIFont systemFontOfSize:17]];
    self.titleLabel.sd_layout.leftSpaceToView(self,15).topSpaceToView(self,10).heightIs(20).widthIs(titleRect);

//    CGRect  contentRect = [ManagerEngine setTextWidthStr:self.contentLabel.text andFont:17];
//    self.contentLabel.sd_layout.leftSpaceToView(self.titleLabel,5).topEqualToView(self.titleLabel).heightIs(20).widthIs(contentRect.size.width);
    
}
-(void)updateLayout {
    
    CGFloat  titleRect = [ManagerEngine setTextWidthStr:self.titleLabel.text andFont:[UIFont systemFontOfSize:17]];
    self.titleLabel.sd_layout.leftSpaceToView(self,15).topSpaceToView(self,10).heightIs(20).widthIs(titleRect);
   
      CGRect contentFrame = [self.contentLabel.text boundingRectWithSize:CGSizeMake(WIDTH-30-titleRect-5, 1000)options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:17]} context:nil];
    self.contentLabel.sd_layout.autoHeightRatio(0);
    self.contentLabel.sd_layout.leftSpaceToView(self.titleLabel,5).topEqualToView(self.titleLabel).heightIs(contentFrame.size.height).widthIs(contentFrame.size.width);
    

//    if ([self.titleLabel.text isEqualToString:@"邮箱"]||[self.titleLabel.text isEqualToString:@"地址"]) {
//        self.contentLabel.textColor = [ManagerEngine getColor:@"323232"];
//    } else if ([self.titleLabel.text isEqualToString:@"积分"]) {
//        
//        self.contentLabel.textColor = [ManagerEngine getColor:@"f54949"];
//
//        
//    } else if ([self.titleLabel.text isEqualToString:@"ZH"]) {
//        self.contentLabel.textColor = [ManagerEngine getColor:@"00ccb8"];
//
//    }else {
//
//    }
    
}
-(void)setModel:(InformationModel *)model {
    
    _model = model;

    if ([self.titleLabel.text isEqualToString:@"姓名:"]) {

        self.contentLabel.text = model.realname;
    } else if ([self.titleLabel.text isEqualToString:@"电话:"]) {
        self.contentLabel.text = model.mobile;

    } else if ([self.titleLabel.text isEqualToString:@"邮箱:"]) {
        self.contentLabel.text = model.email;
        self.contentLabel.textColor = [ManagerEngine getColor:@"323232"];

    }else if ([self.titleLabel.text isEqualToString:@"身份证:"]) {
        self.contentLabel.text = model.identitynum;

    }else if ([self.titleLabel.text isEqualToString:@"地址:"]) {
        self.contentLabel.text = model.address;
        self.contentLabel.textColor = [ManagerEngine getColor:@"323232"];

    }else if ([self.titleLabel.text isEqualToString:@"积分:"]) {
        self.contentLabel.text = model.bonus;
        self.contentLabel.textColor = [ManagerEngine getColor:@"f54949"];

    }else if ([self.titleLabel.text isEqualToString:@"ZH值:"]) {
        self.contentLabel.text = model.ZH;
        self.contentLabel.textColor = [ManagerEngine getColor:@"00ccb8"];

    }else if ([self.titleLabel.text isEqualToString:@"引荐人:"]) {
        self.contentLabel.text = model.devloper_name;

    }else if ([self.titleLabel.text isEqualToString:@"自身资质:"]) {
        self.contentLabel.text = model.arr;

    }else if ([self.titleLabel.text isEqualToString:@"服务商类型:"]) {
        self.contentLabel.text = model.deposit;

    }else if ([self.titleLabel.text isEqualToString:@"地区:"]) {
        self.contentLabel.text = model.identityarea;
        HQJLog(@"===identityarea:%@\n%@",self.titleLabel.text,model.identityarea);

    }
    
    
    
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
